from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
d=webdriver.Firefox()
d.get('file:///E:/%E8%93%AC%E8%8E%B1%E5%B0%8F%E8%AF%BE2024%E6%B5%8B%E8%AF%95/%E7%AC%AC%E5%9B%9B%E9%98%B6%E6%AE%B5/Selenium%E8%87%AA%E5%8A%A8%E5%8C%96/selenium_demo/day03demo/demo02.html')
data_name='lili'
data_psw='123456'
data_mesg='hello'
#使用页面元素索引号
myname=d.find_element_by_xpath('//input[1]')
myname.clear()
myname.send_keys(data_name)
sleep(2)
mypsw=d.find_element_by_xpath('//input[2]')
mypsw.clear()
mypsw.send_keys(data_psw)
sleep(2)
#使用页面元素属性值
mymesg=d.find_element(By.XPATH,'//textarea')
mymesg.clear()
mymesg.send_keys(data_mesg)
sleep(2)
mysubmit=d.find_element_by_xpath('//input[3]')
mysubmit.click()
sleep(2)
d.quit()
